<template>
  <div>
    <el-dialog
      v-model="state.show"
      title="选择核销币种"
      width="520px"
      modal-class="unReconciled-dailog"
    >
      <el-form label-suffix="：" label-width="50px" size="small">
        <el-form-item label="币种">
          <el-select
            v-model="state.currency"
            placeholder="请选择"
            style="width: 100%"
            clearable
            filterable
          >
            <el-option
              v-for="(item, index) in state.currencys"
              :key="index"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <p style="margin: 12px 0; font-size: 12px; color: #29577e">
          您所勾选的对账单中有多个币种，请选择需核销的币种以生成该币种的未销费用收付款单。
        </p>
      </el-form>

      <template #footer>
        <div>
          <el-button type="default" @click="state.show = false">取消</el-button>
          <el-button type="primary" @click="modifySubmit">确定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted, defineProps, defineEmits } from "vue";
import request from "@/public/request";
import { ElMessage } from "element-plus";
import { useRoute, useRouter } from "vue-router";

const props = defineProps({
  DocType: {
    type: Number,
    required: true,
  },
});
const state = reactive({
  show: false,
  formTitle: "",
  currency: null,
  currencys: [], //币种选择数据
  selectedIds: [],
});

const router = useRouter();

const openDialog = async (currencys, selectedIds) => {
  state.show = true;
  state.currency = currencys[0];
  state.currencys = [];
  currencys.forEach((item) => {
    let valueObj = {
      label: item,
      value: item,
    };
    state.currencys.push(valueObj);
  });
  state.selectedIds = selectedIds;
};

// 批量销账
const modifySubmit = async () => {
  state.show = false;
  if (props.DocType == 1) {
    router.openTab({
      path: `/financial/cashnew`,
      query: {
        title: `新增收款`,
        selectedIds: JSON.stringify(state.selectedIds),
        currency: state.currency,
      },
    });
  } else if (props.DocType == 0) {
    router.openTab({
      path: `/financial/cashOutnew`,
      query: {
        title: `新增付款`,
        selectedIds: JSON.stringify(state.selectedIds),
        currency: state.currency,
      },
    });
  }
};
</script>

<style scoped></style>
<!-- <style lang="scss">
.unReconciled-dailog {
    .el-dialog__header {
        border-bottom: 1px solid #e8e8e8;
    }

    .el-dialog__footer {
        border-top: 1px solid #e8e8e8;

        div {
            display: flex;
            justify-content: flex-end;
            align-items: center;
        }
    }
}
</style> -->
